@extends('admin.layout')
@section('title','新增管理员')
@section('content')
    <h2>新增管理员</h2>
    <div class="input_dl">
        <form name="myform" method="post" action="add-user">
            @csrf
            <div class="dl_one"><label>用户名：</label><input type="text" name="name" id="name" value=""></div><br>
            <div class="dl_two"><label>密  码：</label><input type="password" name="password" id="password" value=""></div><br>
            <div class="dl_two"><label>确认密码：</label><input type="password" name="password_confirmation" id="password_confirmation" value=""></div><br>
            <div class="dl_btn">
                <input name="dosubmit" type="button" value="确定" class="btn_p" onclick="check()">
            </div>
        </form>
    </div>

    <script>
        function check(){
            var name=$("#name").val();
            var password=$("#password").val();
            var password_confirmation=$("#password_confirmation").val();
            var _token="{{csrf_token()}}";
            $.post('/adm/user/add-user',
                {'name':name,'password':password,'password_confirmation':password_confirmation,'_token':_token},
                function (data){
                    if(data.success){
                        alert("新用户已成功创建");
                        location.href='/adm/userlist';
                    }
                    else{
                        alert(data.msg);
                    }
                },'json');
        }
    </script>
@endsection
